{extend name='common/common' /}

{block name="style"}
<style type="text/css">
    a:hover{
      text-decoration:underline;
      color:#ff00ff;
    }
    a{
        color：#888;!important;
    }
    .container-fluid .btn.btn-sm{
        float: right;
        margin-left: 10px;
    }
    .container-fluid{
        padding-right: 0px;
    }
    tr{
        cursor: pointer;
    }
    .layui-form-item{
        margin-bottom: 0px;
    }
    .layui-form{
        display: inline-block;
    }
</style>
{/block}

{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>我的订单列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始 pull-right-->
            <form id='commentForm' role="form" method="post" class="form-inline pull-left">
                <div class="content clearfix m-b">
                    <?php if(authCheck('member/director')):?>
                        <div class="form-group">
                            <label>部门：</label>
                            <select class="form-control"  name="depart_id" id="depart_id">
                                <option value="">请选择</option>
                                <?=$dep_Arr;?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>咨询师姓名：</label>
                            <select class="form-control"  name="user_id" id="user_id">
                                <option value="">请选择</option>
                                <?php foreach($departUserArr as $val):?>
                                    <option value="<?=$val['id']?>"><?=$val['real_name']?></option>>
                                <?php endforeach;?>
                            </select>
                        </div>
                    <?php endif;?>

                    <div class="form-group">
                        <label>姓名：</label>
                        <input type="text" class="form-control" id="stu_name" name="name">
                    </div>
                    <!-- 新增时间  -->
                    <div class="form-group">
                        <label>日期范围：</label>
                        <div class="layui-form">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" name="KL-time" id="KL-time" placeholder="开始 到 结束">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
                        </button>
                    </div>
                </div>
            </form>
            <!--搜索框结束-->

            <div class="example-wrap">
                <div class="example">
                    <table id="cusTable">
                        <thead>
                        <!-- <th>checkbox</th> -->
                        <th class="text-center" data-width="100px" data-field="id">订单ID</th>
                        <th class="text-center" data-width="150px" data-field="order_sn">订单号</th>
                        <th class="text-center" data-width="100px" data-field="stu_name">姓名</th>
                        <th class="text-center" data-width="120px" data-field="phone">联系电话</th>
                        <th class="text-center" data-width="200px" data-field="school">报考学院</th>
                        <th class="text-center" data-width="200px" data-field="major">专业</th>
                        <th class="text-center" data-width="100px" data-field="gradeN">层次</th>
                        <th class="text-center" data-width="100px" data-field="acquisition_mode">教育模式</th>
                        <th class="text-center" data-width="100px" data-field="total_amount">总金额(元)</th>
                        <th class="text-center" data-width="100px" data-field="payment_methodN">分期方式</th>
                        <th class="text-center" data-width="100px" data-field="pay_typeN">支付方式</th>
                        <th class="text-center" data-width="100px" data-field="consultantN">所属咨询师</th>
                        <th class="text-center" data-width="120px" data-field="operate">操作</th>
                        </thead>
                    </table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
<div id="remarks" style="display: none;padding: 15px;"></div>
<div class="laycontent" style="display: none;width: 300px;padding: 30px 15px;">
    <ul id="tree"></ul>
</div>
{/block}


{block name="script"}
<script type="text/javascript">
    function initTable() {
        //先销毁表格
        $('#cusTable').bootstrapTable('destroy');
        //初始化表格,动态从服务器加载数据
        $("#cusTable").bootstrapTable({
            method: "get",  //使用get请求到服务器获取数据
            url: "{:url('Business/MyOrder')}", //获取数据的地址
            striped: true,  //表格显示条纹
            pagination: true, //启动分页
            pageSize: 10,  //每页显示的记录数
            pageNumber:1, //当前第几页
            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
            sidePagination: "server", //表示服务端请求
						resizable:true,//可变宽列表
            paginationFirstText: "首页",
            paginationPreText: "上一页",
            paginationNextText: "下一页",
            paginationLastText: "尾页",
            queryParamsType : "undefined",
            columns : [{
                checkbox: false,
                formatter:function(value,row,index){
                    if (row.state == true){
                        return {
                            checked : value,//设置选中
                        };
                    }
                    return value;
                },
            }],
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    stu_name:$('#stu_name').val(),
                    c_time:$('#KL-time').val(),
                    user_id:$('#user_id').val(),//咨询师名字
                    depart_id:$('#depart_id').val(),//部门id
                };
                return param;
            },
            onLoadSuccess: function(res){ //加载成功时执行
                if(111 == res.code){
                    window.location.reload();
                }
                layer.msg("加载成功", {time : 1000});
            },
            onLoadError: function(){  //加载失败时执行
                layer.msg("加载数据失败");
            },
            onDblClickRow: function (row) {
                $("#remarks").html(row.remarks);
                layer.open({
                    type: 1,
                    skin: 'layui-layer-lan', //加上边框
                    area: ['300px', '300px'], //宽高
                    content: $("#remarks"),
                    title: '备注信息'
                });
            }
        });
    }

    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();

        //当点击查询按钮的时候执行
        $("#search").bind("click", initTable);

        $('.getIDs').on('click',function(){
            var checkedOn= $('#cusTable').bootstrapTable('getSelections');
            var IDs = '';
            for(var i=0;i<checkedOn.length;i++){
                if(i == 0){
                    IDs = checkedOn[0].id;
                }else{
                    IDs += ',' + checkedOn[i].id;
                }
            }
            $('.getIDs').attr('data-param',IDs);
        })
    });
    //时间选择
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#KL-time'
            ,range: true
        });
    })
</script>
<script>
// Ajax 改变不同部门时的不同职员
$(function(){
	$('#depart_id').on('change',function(){
		var depart_id = $('#depart_id').val();
		$.post("{:url('member/departUser')}",{
			depart_id : depart_id
		},function(res){
			if(res.code == 1){
				var data = res.data;
				var app = '<option value="">请选择</option>';
				for(var i in data){
					app += '<option value="'+data[i]["id"]+'">'+data[i]["real_name"]+'</option>'
				}
				$('#user_id').html(app);
			}
		})
	})
})
</script>
{/block}
